<?php $this->fetch('public/head') ?>
<div class="layui-tab layui-tab-brief">
    <ul class="layui-tab-title">
        <li class=""><a href="<?php echo url('hsnav/index') ?>">导航管理</a></li>
        <li class="<?php echo $nav['id']?'':'layui-this' ?>"><a href="<?php echo url('hsnav/edit') ?>">添加导航</a></li>
        <?php if($nav['id']>0): ?><li class="layui-this">编辑导航</li><?php endif; ?>
    </ul>
    <?php language_tab();//多语言tab ?>
    <div class="layui-tab-content">
        <div class="layui-tab-item layui-show">
            <form class="layui-form form-container" action="<?php echo url('hsnav/save') ?>" method="post">
                <div class="layui-form-item">
                    <label class="layui-form-label">所属分类</label>
                    <div class="layui-input-block">
                        <select name="nav_cid" required lay-verify="required">
                            <?php foreach($navcat_list as $k=>$v): ?>
                        	<option value="<?php echo $k ?>" <?php if($k==$nav['nav_cid'] || $nav_cid==$k){echo 'selected="selected"';} ?>><?php echo $v ?></option>
                           	<?php endforeach; ?>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">上级导航</label>
                    <div class="layui-input-block">
                        <select name="pid" required lay-verify="required">
                            <option value="0">一级导航</option>
                            <?php foreach($nav_level_list as $v): ?>
                            <option value="<?php echo $v['id'] ?>" <?php if($nav['id']==$v['id']){echo 'disabled="disabled"';} ?> <?php if($nav['pid']==$v['id'] || $pid==$v['id']){echo 'selected="selected"';} ?>><?php if($v['level']!=1){for($i=1;$i<$v['level'];$i++){echo '----';}}echo $v['name_cn'],$v['name_en']?' - '.$v['name_en']:''; ?></option>
                            <?php endforeach; ?>
                        </select>
                    </div>
                </div>
                <div class="list_0 layui-form-item">
                    <label class="layui-form-label">导航名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="name_cn" value="<?php echo $nav['name_cn'] ?>" required  lay-verify="required" placeholder="请输入导航名称" class="layui-input">
                    </div>
                </div>
                <div class="list_1 layui-form-item">
                    <label class="layui-form-label">导航名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="name_en" value="<?php echo $nav['name_en'] ?>" placeholder="请输入导航名称" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">链接</label>
                    <div class="layui-input-block">
                        <input type="text" name="link" value="<?php echo $nav['link'] ?>" placeholder="（选填）请输入导航链接" class="layui-input">
                    </div>
                </div>
                <div class="list_0 layui-form-item">
                    <label class="layui-form-label">图片</label>
                    <div class="layui-upload">
                    <input type="text" name="img_url_cn" value="<?php echo $nav['img_url_cn'] ?>" class="layui-input layui-input-inline">
                        <button type="button" class="layui-btn _img_url" lay-data="{data:{max_width:1920,max_height:400,path:'nav'}}"><i class="layui-icon">&#xe67c;</i>上传图片</button>
                        <img src="<?php echo $nav['img_url_cn'] ?>" height="38" data-expander=''>
                        仅允许上传jpg,png,gif,jpeg格式，推荐尺寸1920*400
                    </div> 
                </div>
                <div class="list_1 layui-form-item">
                    <label class="layui-form-label">图片</label>
                    <div class="layui-upload">
                        <input type="text" name="img_url_en" value="<?php echo $nav['img_url_en'] ?>" class="layui-input layui-input-inline">
                        <button type="button" class="layui-btn _img_url" lay-data="{data:{max_width:1920,max_height:400,path:'nav'}}"><i class="layui-icon">&#xe67c;</i>上传图片</button>
                        <img src="<?php echo $nav['img_url_en'] ?>" height="38" data-expander=''>
                        仅允许上传jpg,png,gif,jpeg格式，推荐尺寸1920*400
                        <a class="layui-btn layui-btn-primary layui-btn-radius" onclick="copy_img('img_url_cn',this)">选取中文图片</a>
                    </div>
                </div>
                <div class="list_0 layui-form-item">
                    <label class="layui-form-label">内容</label>
                    <div class="layui-input-block">
                        <textarea id="editor" name="content_cn" class="layui-textarea" style="height: 200px;"><?php echo $nav['content_cn'] ?></textarea>
                    </div>
                </div>
                <div class="list_1 layui-form-item">
                    <label class="layui-form-label">内容</label>
                    <div class="layui-input-block">
                        <textarea id="editor2" name="content_en" class="layui-textarea" style="height: 200px;"><?php echo $nav['content_en'] ?></textarea>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">类型</label>
                    <div class="layui-input-block">
                        <input type="radio" name="model" value="1" title="列表" <?php if($nav['model']==1){echo 'checked="checked"';} ?>>
                        <input type="radio" name="model" value="2" title="单页" <?php if($nav['model']==2){echo 'checked="checked"';} ?>>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">状态</label>
                    <div class="layui-input-block">
                        <input type="radio" name="status" value="1" title="显示" <?php if($nav['status']==1 || !$nav['id']){echo 'checked="checked"';} ?>>
                        <input type="radio" name="status" value="0" title="隐藏" <?php if($nav['status']===0){echo 'checked="checked"';} ?>>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">打开方式</label>
                    <div class="layui-input-block">
                        <input type="radio" name="target" value="_self" title="默认" <?php if($nav['target']=='_self' || !$nav['id']){echo 'checked="checked"';} ?>>
                        <input type="radio" name="target" value="_blank" title="新窗口" <?php if($nav['target']=='_blank'){echo 'checked="checked"';} ?>>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">排序</label>
                    <div class="layui-input-block">
                        <input type="text" name="sort" value="<?php echo $nav['sort']?:'0' ?>" required  lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <input type="hidden" name="id" value="<?php echo $nav['id'] ?>">
                        <button class="layui-btn" lay-submit lay-filter="*">保存</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<?php $this->fetch('public/script') ?>